<?php


namespace app\common\model;
use think\Paginator;
/**
 * 处理用户收藏相关数据
 * Class Like
 * @package app\common\model
 */
class Like extends Base
{
    /**
     * @param number $uid 用户user_id
     * @param number $type 收藏类别 1 视频 2 音乐
     * @param number $page 页码数量 默认20条
     * @return array $data 指定页码收藏数据
     */
    public function get_user_like($uid,$type=1,$nowPage=1,$limits=10)
    {
        if(!isset($uid) || !is_numeric($uid) || $type != 1 && $type != 2) {
            exception('非法传参');
        }
        $data = [
            'user_id' => $uid,
            'is_type' => $type
        ];
        return $this->where($data)->page($nowPage,$limits)->select();
    }

    public function get_user_like_count($uid,$type=1)
    {
        if(!isset($uid) || !is_numeric($uid) || $type != 1 && $type != 2) {
            exception('非法传参');
        }
        $data = [
            'user_id' => $uid,
            'is_type' => $type
        ];
        return $this->where($data)->count();
    }
}